package cn.source.web.controller.scontent;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import cn.source.common.annotation.Log;
import cn.source.common.core.controller.BaseController;
import cn.source.common.core.domain.AjaxResult;
import cn.source.common.enums.BusinessType;
import cn.source.scontent.domain.SContent;
import cn.source.scontent.service.ISContentService;
import cn.source.common.utils.poi.ExcelUtil;
import cn.source.common.core.page.TableDataInfo;

/**
 * scontentController
 *
 * @author xuhao
 * @date 2023-12-19
 */
@RestController
@RequestMapping("/scontent/scontent")
public class SContentController extends BaseController
{
    @Autowired
    private ISContentService sContentService;

    /**
     * 查询scontent列表
     */
    @PreAuthorize("@ss.hasPermi('scontent:scontent:list')")
    @GetMapping("/list")
    public TableDataInfo list(SContent sContent)
    {
        startPage();
        List<SContent> list = sContentService.selectSContentList(sContent);
        return getDataTable(list);
    }

    /**
     * 导出scontent列表
     */
    @PreAuthorize("@ss.hasPermi('scontent:scontent:export')")
    @Log(title = "scontent", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SContent sContent)
    {
        List<SContent> list = sContentService.selectSContentList(sContent);
        ExcelUtil<SContent> util = new ExcelUtil<SContent>(SContent.class);
        util.exportExcel(response, list, "scontent数据");
    }

    /**
     * 获取scontent详细信息
     */
    @PreAuthorize("@ss.hasPermi('scontent:scontent:query')")
    @GetMapping(value = "/{iId}")
    public AjaxResult getInfo(@PathVariable("iId") Long iId)
    {
        return AjaxResult.success(sContentService.selectSContentByIId(iId));
    }

    /**
     * 新增scontent
     */
    @PreAuthorize("@ss.hasPermi('scontent:scontent:add')")
    @Log(title = "scontent", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SContent sContent)
    {
        return toAjax(sContentService.insertSContent(sContent));
    }

    /**
     * 修改scontent
     */
    @PreAuthorize("@ss.hasPermi('scontent:scontent:edit')")
    @Log(title = "scontent", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SContent sContent)
    {
        return toAjax(sContentService.updateSContent(sContent));
    }

    /**
     * 删除scontent
     */
    @PreAuthorize("@ss.hasPermi('scontent:scontent:remove')")
    @Log(title = "scontent", businessType = BusinessType.DELETE)
	@DeleteMapping("/{iIds}")
    public AjaxResult remove(@PathVariable Long[] iIds)
    {
        return toAjax(sContentService.deleteSContentByIIds(iIds));
    }
}
